{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from dataloader import getdata\n",
    "from util import *\n",
    "from sklearn import preprocessing\n",
    "import xgboost as xgb\n",
    "import numpy as np\n",
    "from matplotlib import pyplot\n",
    "from sklearn.model_selection import GridSearchCV\n",
    "\n",
    "RANDOM_SEEDS = 95\n",
    "# standard_scaler min_max_scaler max_abs_scaler normalizer\n",
    "PROCESSES_TYPE = 'normalizer'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[读取数据] done in 25.67 s\n"
     ]
    }
   ],
   "source": [
    "with timer('读取数据'):\n",
    "    md_train, md_test, er_train, er_test, ad_train, ad_test,molecular_train,molecular_test = getdata()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/kuroneko/anaconda3/envs/ML/lib/python3.7/site-packages/ipykernel_launcher.py:14: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  \n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[数据预处理] done in 0.38 s\n"
     ]
    }
   ],
   "source": [
    "#dataloader\n",
    "with timer('数据预处理'):\n",
    "    # (1974, 729)\n",
    "    x = md_train.loc[:,'nAcid':'Zagreb'].to_numpy()\n",
    "    # (1974, 1)\n",
    "    y = er_train.loc[:,'pIC50']\n",
    "    q2_test = md_test.loc[:,'nAcid':'Zagreb'].to_numpy()\n",
    "    feature_name = [column for column in md_train][1:]\n",
    "    data_len = len(y)\n",
    "    \n",
    "    np.random.seed(RANDOM_SEEDS)\n",
    "    np.random.shuffle(x)\n",
    "    np.random.seed(RANDOM_SEEDS)\n",
    "    np.random.shuffle(y)\n",
    "    \n",
    "    x_train = processes(x[:int(data_len*0.8)],PROCESSES_TYPE)\n",
    "    x_dev = processes(x[int(data_len*0.8):],PROCESSES_TYPE)\n",
    "    \n",
    "    y_train = y[:int(data_len*0.8)]\n",
    "    y_dev = y[int(data_len*0.8):]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_xgb_imp(xgb, feat_names):\n",
    "    from numpy import array\n",
    "    imp_vals = xgb.get_booster().get_fscore()\n",
    "    imp_dict = {feat_names[i]:float(imp_vals.get('f'+str(i),0.)) for i in range(len(feat_names))}\n",
    "    total = array(imp_dict.values()).sum()\n",
    "    return {k:v/total for k,v in imp_dict.items()}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "def turning(other_param,search_param,x,y):\n",
    "    with timer('train model'):\n",
    "        model = xgb.XGBRegressor(**other_param)\n",
    "        search = GridSearchCV(model,search_param)\n",
    "        search.fit(x,y)\n",
    "    print('参数的最佳取值：{0}'.format(search.best_params_))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[train model] done in 9.41 s\n",
      "参数的最佳取值：{'n_estimators': 70}\n"
     ]
    }
   ],
   "source": [
    "other_params = {  # 固定的参数\n",
    "    'learning_rate':0.07, # 需调参 \n",
    "    'n_estimators':700,# 需调参 \n",
    "    'max_depth':20, # 需调参 \n",
    "    'min_child_weight':1, # 需调参 \n",
    "    'gamma':0.2, # 需调参 \n",
    "    'colsample_bytree':0.2, # 需调参 \n",
    "}\n",
    "\n",
    "# cv_params = {'n_estimators':[700,800,900,1000,1100,1200,1300,1400]} # 正在调参\n",
    "cv_params = {'n_estimators':[70]} # 正在调参\n",
    "\n",
    "# q1 模型 输入700多维特征\n",
    "best_param = turning(other_param,cv_params,x,y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "XGBRegressor(base_score=0.5, booster='gbtree', colsample_bylevel=1,\n",
       "             colsample_bynode=1, colsample_bytree=0.2, gamma=0.2, gpu_id=-1,\n",
       "             importance_type='gain', interaction_constraints='',\n",
       "             learning_rate=0.07, max_delta_step=0, max_depth=20,\n",
       "             min_child_weight=1, missing=nan, monotone_constraints='()',\n",
       "             n_estimators=700, n_jobs=8, num_parallel_tree=1, random_state=0,\n",
       "             reg_alpha=0, reg_lambda=1, scale_pos_weight=1, subsample=1,\n",
       "             tree_method='exact', validate_parameters=1, verbosity=None)"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# q1 模型\n",
    "q1_model = xgb.XGBRegressor(**other_params)\n",
    "q1_model.fit(x,y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [],
   "source": [
    "importance_dict = q1_model.get_booster().get_score(importance_type='gain')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'f406': 79.44894117404763,\n",
       " 'f476': 23.606217023799996,\n",
       " 'f62': 9.614659507719999,\n",
       " 'f428': 1.8662636714,\n",
       " 'f520': 1.8951492316,\n",
       " 'f532': 1.096664966,\n",
       " 'f8': 1.2722078671818184,\n",
       " 'f35': 16.57106696941144,\n",
       " 'f22': 2.943299945673171,\n",
       " 'f166': 14.838256860000001,\n",
       " 'f706': 8.9577983844,\n",
       " 'f25': 0.7890213881789473,\n",
       " 'f410': 4.171081631193671,\n",
       " 'f112': 1.3894648965999998,\n",
       " 'f351': 6.812646426732,\n",
       " 'f102': 6.030746377687501,\n",
       " 'f488': 1.7209303313777777,\n",
       " 'f388': 0.4348192119368421,\n",
       " 'f31': 0.7575821626285715,\n",
       " 'f11': 183.9183373243333,\n",
       " 'f119': 93.0659279318,\n",
       " 'f163': 51.9213867,\n",
       " 'f642': 11.547519797,\n",
       " 'f523': 28.936796855333338,\n",
       " 'f92': 2.07986236372,\n",
       " 'f45': 0.8155959168571429,\n",
       " 'f723': 2.791209052953061,\n",
       " 'f622': 1.5952142732764703,\n",
       " 'f106': 0.987089142,\n",
       " 'f94': 0.28932984047941174,\n",
       " 'f716': 3.5656482019949998,\n",
       " 'f294': 0.7949552390266669,\n",
       " 'f352': 3.5270423667178554,\n",
       " 'f157': 18.3046875,\n",
       " 'f721': 1.4643406665357137,\n",
       " 'f85': 1.9321627149047615,\n",
       " 'f103': 0.662233393054902,\n",
       " 'f725': 0.7121836312999998,\n",
       " 'f659': 47.8516341917143,\n",
       " 'f673': 8.586037512433332,\n",
       " 'f86': 4.684183082270371,\n",
       " 'f309': 0.7136680797166667,\n",
       " 'f58': 5.795070347500001,\n",
       " 'f475': 0.881301196182222,\n",
       " 'f347': 1.5536058058999997,\n",
       " 'f293': 1.4984261119733333,\n",
       " 'f592': 3.011732990946153,\n",
       " 'f412': 0.3110085375142857,\n",
       " 'f23': 3.386086235028571,\n",
       " 'f512': 1.7012864510166665,\n",
       " 'f724': 2.2068305502456527,\n",
       " 'f678': 0.45007638613749995,\n",
       " 'f44': 0.751955384492857,\n",
       " 'f652': 47.200988380811765,\n",
       " 'f357': 27.31943041770556,\n",
       " 'f3': 0.8839272518421051,\n",
       " 'f392': 2.3460254702488883,\n",
       " 'f671': 1.045086436569231,\n",
       " 'f82': 1.1483839755656247,\n",
       " 'f584': 2.049410236329412,\n",
       " 'f393': 0.7994641023962961,\n",
       " 'f134': 0.509596362625,\n",
       " 'f368': 0.8216741679999999,\n",
       " 'f33': 1.6190133375666669,\n",
       " 'f274': 1.2251678872121214,\n",
       " 'f385': 0.5073355323388891,\n",
       " 'f585': 1.8289662539547613,\n",
       " 'f389': 3.9625920023793095,\n",
       " 'f53': 0.6937538653538464,\n",
       " 'f26': 1.4516617246347823,\n",
       " 'f374': 1.5616094215714291,\n",
       " 'f167': 1.9708000816666669,\n",
       " 'f237': 1.8116987998939391,\n",
       " 'f601': 0.6647119243636364,\n",
       " 'f39': 8.815420041134,\n",
       " 'f506': 4.9403178191,\n",
       " 'f270': 1.0324728460888888,\n",
       " 'f99': 0.8509800759842105,\n",
       " 'f620': 1.0080982214818182,\n",
       " 'f411': 3.744518529794286,\n",
       " 'f634': 0.5234852430766666,\n",
       " 'f60': 1.7631784184545454,\n",
       " 'f603': 0.3367149313333334,\n",
       " 'f97': 2.5668380977952383,\n",
       " 'f656': 0.7966096851558827,\n",
       " 'f356': 4.364835027029167,\n",
       " 'f95': 0.6694953162888888,\n",
       " 'f269': 1.2056630264146337,\n",
       " 'f481': 6.7681547822,\n",
       " 'f683': 1.9635130322111118,\n",
       " 'f46': 0.7187815622166666,\n",
       " 'f594': 11.302506391333333,\n",
       " 'f727': 2.0109162533937504,\n",
       " 'f73': 0.7005124717266668,\n",
       " 'f463': 1.1833174721379314,\n",
       " 'f24': 0.6338712585463769,\n",
       " 'f42': 3.0761668840428587,\n",
       " 'f12': 0.6298706157894736,\n",
       " 'f100': 0.9150605121954546,\n",
       " 'f346': 0.6806500493039473,\n",
       " 'f504': 0.4259704521192308,\n",
       " 'f662': 1.3186948941818184,\n",
       " 'f229': 0.9353601165600001,\n",
       " 'f115': 0.4208166483769231,\n",
       " 'f639': 13.334492495090904,\n",
       " 'f616': 2.464515961883334,\n",
       " 'f90': 2.1212819820357143,\n",
       " 'f233': 1.4214318098848482,\n",
       " 'f373': 0.5463196194500001,\n",
       " 'f4': 0.4437072273636364,\n",
       " 'f41': 0.5814517634500002,\n",
       " 'f18': 0.65379047375,\n",
       " 'f66': 1.3510498736948717,\n",
       " 'f658': 1.4017421842071425,\n",
       " 'f698': 4.564235357285715,\n",
       " 'f113': 0.41554588075,\n",
       " 'f413': 1.8016559079260868,\n",
       " 'f645': 1.0320378911400003,\n",
       " 'f383': 0.26611688846785725,\n",
       " 'f105': 0.946468120427273,\n",
       " 'f350': 1.907326286883333,\n",
       " 'f614': 0.35787546332666664,\n",
       " 'f255': 0.6701811242117646,\n",
       " 'f334': 0.3486104425357142,\n",
       " 'f265': 1.629844665,\n",
       " 'f27': 0.7749384698888889,\n",
       " 'f230': 0.4570911641423078,\n",
       " 'f147': 0.4267325146736843,\n",
       " 'f473': 2.201321536658334,\n",
       " 'f655': 0.37390869890800005,\n",
       " 'f529': 4.003118802994737,\n",
       " 'f590': 0.9571264466861114,\n",
       " 'f241': 1.6811218265,\n",
       " 'f527': 1.1038875315555554,\n",
       " 'f83': 1.2685559879694448,\n",
       " 'f232': 1.7356331271822218,\n",
       " 'f89': 0.70588918553,\n",
       " 'f372': 0.536469768764706,\n",
       " 'f76': 1.0339535467999998,\n",
       " 'f465': 1.203147648,\n",
       " 'f9': 0.8139464443200002,\n",
       " 'f647': 0.46858474073684203,\n",
       " 'f586': 1.1437910881533335,\n",
       " 'f587': 15.379518145349996,\n",
       " 'f583': 1.1520639044607142,\n",
       " 'f36': 2.0494531776666665,\n",
       " 'f7': 1.1204624838928572,\n",
       " 'f547': 1.1376429353,\n",
       " 'f611': 1.4916160326,\n",
       " 'f665': 3.6629069540852184,\n",
       " 'f470': 3.870322274169144,\n",
       " 'f354': 1.930117505571429,\n",
       " 'f81': 0.8233346846826086,\n",
       " 'f602': 0.4525217847230769,\n",
       " 'f712': 9.29040525,\n",
       " 'f404': 6.774567788999998,\n",
       " 'f361': 4.396639303200001,\n",
       " 'f59': 2.08166098275,\n",
       " 'f75': 1.061150077651667,\n",
       " 'f625': 0.948372982090909,\n",
       " 'f110': 0.6141427366666666,\n",
       " 'f172': 16.418867589525,\n",
       " 'f654': 1.2075422703,\n",
       " 'f40': 0.7046318918773808,\n",
       " 'f471': 0.6918855492187501,\n",
       " 'f629': 0.2809972883148149,\n",
       " 'f13': 0.9688219741176473,\n",
       " 'f79': 1.3619136666774194,\n",
       " 'f490': 1.3510092982571429,\n",
       " 'f589': 0.6055870533524998,\n",
       " 'f84': 0.6723027557200004,\n",
       " 'f291': 0.9449107520400003,\n",
       " 'f474': 0.5851371890071428,\n",
       " 'f610': 0.48645270180999994,\n",
       " 'f666': 0.29087568261875,\n",
       " 'f703': 10.1104483495,\n",
       " 'f56': 14.5082929643,\n",
       " 'f154': 3.5181062230000006,\n",
       " 'f285': 1.7726885509250003,\n",
       " 'f367': 0.212402344,\n",
       " 'f531': 15.832336294588234,\n",
       " 'f344': 0.6111441675136364,\n",
       " 'f286': 1.0098034015033333,\n",
       " 'f469': 0.9820858808095233,\n",
       " 'f664': 0.9624447703,\n",
       " 'f387': 0.8489797610411765,\n",
       " 'f91': 0.5047298447,\n",
       " 'f480': 0.9135014341777778,\n",
       " 'f606': 1.152604705714706,\n",
       " 'f231': 0.9636838290806451,\n",
       " 'f394': 2.0915141547,\n",
       " 'f660': 1.0863063754066666,\n",
       " 'f65': 0.7845938980999998,\n",
       " 'f116': 2.253346965,\n",
       " 'f1': 0.9993069640590907,\n",
       " 'f6': 0.44779777525000003,\n",
       " 'f593': 0.7903606775611111,\n",
       " 'f316': 0.29768786515,\n",
       " 'f353': 0.7679177016075,\n",
       " 'f98': 0.4982470209628571,\n",
       " 'f679': 0.4370956507032257,\n",
       " 'f132': 0.29996109,\n",
       " 'f491': 0.6456762145538462,\n",
       " 'f313': 0.6818494790000001,\n",
       " 'f524': 0.8088347805363637,\n",
       " 'f717': 14.7231902059,\n",
       " 'f674': 0.8362608084970586,\n",
       " 'f150': 5.277107422199999,\n",
       " 'f234': 0.633951397317647,\n",
       " 'f511': 0.8127833316083334,\n",
       " 'f0': 0.26504474865,\n",
       " 'f467': 2.6624725703125005,\n",
       " 'f64': 1.59869385,\n",
       " 'f72': 0.7346211183666665,\n",
       " 'f47': 0.8352511010764706,\n",
       " 'f670': 0.7609836265000002,\n",
       " 'f21': 1.6609913934410252,\n",
       " 'f472': 1.1407608221384615,\n",
       " 'f268': 0.8056364385909088,\n",
       " 'f249': 1.941644873578571,\n",
       " 'f638': 0.5727359135555555,\n",
       " 'f254': 1.2002642497142857,\n",
       " 'f530': 0.6250037049772729,\n",
       " 'f508': 6.144153598500001,\n",
       " 'f243': 2.057169016399999,\n",
       " 'f675': 1.3237169864478262,\n",
       " 'f253': 0.9643378323888889,\n",
       " 'f93': 0.9406071533625002,\n",
       " 'f371': 0.3480652498806452,\n",
       " 'f623': 1.3261132236923077,\n",
       " 'f145': 0.22964257,\n",
       " 'f273': 0.9886645075710526,\n",
       " 'f38': 0.837697649666667,\n",
       " 'f626': 0.8007753035882352,\n",
       " 'f648': 3.9911488973937503,\n",
       " 'f600': 0.4270962124090909,\n",
       " 'f493': 0.41913875472758616,\n",
       " 'f136': 0.5875989128888889,\n",
       " 'f604': 0.3615682879111111,\n",
       " 'f635': 0.19831439665,\n",
       " 'f705': 1.9842942352500001,\n",
       " 'f598': 0.6523282213444443,\n",
       " 'f32': 0.4161240743777778,\n",
       " 'f275': 0.44562679011999995,\n",
       " 'f88': 3.2570230481999998,\n",
       " 'f247': 0.7276110925,\n",
       " 'f2': 0.3710828616368421,\n",
       " 'f227': 0.2998680035260869,\n",
       " 'f525': 7.7205935128235295,\n",
       " 'f57': 1.7607853414285715,\n",
       " 'f77': 0.6174696735695651,\n",
       " 'f362': 3.7511078516666667,\n",
       " 'f133': 0.9318400991666665,\n",
       " 'f61': 0.6019937505999999,\n",
       " 'f507': 0.636862555975,\n",
       " 'f135': 0.715057373,\n",
       " 'f287': 0.6505684921428573,\n",
       " 'f310': 0.38780975349999997,\n",
       " 'f657': 1.2383789299999999,\n",
       " 'f699': 1.1631340973333333,\n",
       " 'f704': 1.48565674,\n",
       " 'f582': 0.6627423547272728,\n",
       " 'f118': 1.3725934835888889,\n",
       " 'f369': 0.49546205536800003,\n",
       " 'f238': 2.3073134626139535,\n",
       " 'f435': 0.20313453491111108,\n",
       " 'f676': 0.7247952874318182,\n",
       " 'f266': 0.23204845212592595,\n",
       " 'f651': 0.5440679092999999,\n",
       " 'f281': 1.2103386525,\n",
       " 'f190': 1.27297211,\n",
       " 'f613': 0.4057677739999999,\n",
       " 'f728': 0.25575311700000003,\n",
       " 'f162': 0.800323486,\n",
       " 'f235': 1.0245095360105263,\n",
       " 'f618': 0.7511869633142858,\n",
       " 'f349': 0.2633107663,\n",
       " 'f360': 0.586139686625,\n",
       " 'f653': 9.493648069909998,\n",
       " 'f692': 4.020310402,\n",
       " 'f519': 0.6552525512888889,\n",
       " 'f264': 0.41013065231481494,\n",
       " 'f650': 0.5318869495608695,\n",
       " 'f432': 0.45378327375,\n",
       " 'f661': 0.9421666601439397,\n",
       " 'f510': 0.21962785699999998,\n",
       " 'f502': 0.5069840996894737,\n",
       " 'f228': 0.4381388599333333,\n",
       " 'f605': 0.4129096976090908,\n",
       " 'f104': 0.5589105439266666,\n",
       " 'f637': 0.9924051478130437,\n",
       " 'f714': 0.8708438079210524,\n",
       " 'f101': 0.36273757667142875,\n",
       " 'f149': 0.48047447219999995,\n",
       " 'f276': 0.45087054362499995,\n",
       " 'f151': 0.50679757338,\n",
       " 'f29': 0.3407425792151515,\n",
       " 'f278': 0.6872781130000001,\n",
       " 'f289': 0.4950698462200001,\n",
       " 'f405': 0.9264318660967743,\n",
       " 'f464': 0.1373096854,\n",
       " 'f627': 0.3281021015354837,\n",
       " 'f453': 0.25275212372,\n",
       " 'f67': 0.5926422805224998,\n",
       " 'f252': 1.0488170236894738,\n",
       " 'f14': 2.0468635563333333,\n",
       " 'f429': 0.2038291235285714,\n",
       " 'f487': 0.7392520030909092,\n",
       " 'f242': 0.3074106694,\n",
       " 'f5': 0.3068334328888888,\n",
       " 'f595': 0.7932102959999999,\n",
       " 'f122': 0.6888229066666667,\n",
       " 'f486': 0.353179932,\n",
       " 'f283': 0.17141914390000002,\n",
       " 'f30': 0.3810435291074073,\n",
       " 'f250': 0.7096079126250002,\n",
       " 'f292': 2.1433732267076926,\n",
       " 'f311': 0.47450267376666666,\n",
       " 'f170': 0.4936857225,\n",
       " 'f69': 0.667397499,\n",
       " 'f468': 0.4305960578058823,\n",
       " 'f695': 1.04910278,\n",
       " 'f74': 0.8505821219999999,\n",
       " 'f591': 0.8844346189533335,\n",
       " 'f503': 0.287811279,\n",
       " 'f175': 0.3197873433333333,\n",
       " 'f236': 0.4430890264851853,\n",
       " 'f612': 0.6798183922500001,\n",
       " 'f636': 0.38640838027837837,\n",
       " 'f713': 2.19421387,\n",
       " 'f631': 0.4945598244166665,\n",
       " 'f710': 0.2089409235,\n",
       " 'f159': 0.3482608795,\n",
       " 'f535': 1.2406909450571428,\n",
       " 'f599': 0.20948155215000003,\n",
       " 'f48': 0.43613149612499996,\n",
       " 'f401': 0.30736247584,\n",
       " 'f355': 0.5387130495342859,\n",
       " 'f168': 0.41699981675,\n",
       " 'f720': 0.5361164960875001,\n",
       " 'f117': 0.2919286938925,\n",
       " 'f43': 0.42564797399999993,\n",
       " 'f521': 0.36196503064999996,\n",
       " 'f391': 0.653564453,\n",
       " 'f395': 0.7029500250714287,\n",
       " 'f108': 0.59457468975,\n",
       " 'f16': 0.58534956,\n",
       " 'f588': 0.4288675264217391,\n",
       " 'f554': 0.301407806675,\n",
       " 'f416': 2.137883562333333,\n",
       " 'f71': 0.736598323195238,\n",
       " 'f225': 0.4610344322538463,\n",
       " 'f684': 1.69327545,\n",
       " 'f649': 0.5346548656666668,\n",
       " 'f624': 0.3414541963162162,\n",
       " 'f226': 0.5314483362666665,\n",
       " 'f197': 0.2405123715,\n",
       " 'f282': 0.35780679389230763,\n",
       " 'f719': 0.5636132248181819,\n",
       " 'f80': 0.5066160131333334,\n",
       " 'f37': 0.33631072913461535,\n",
       " 'f111': 0.34246051325,\n",
       " 'f514': 1.4710437664999998,\n",
       " 'f345': 1.4332061055333334,\n",
       " 'f297': 0.6411258014153846,\n",
       " 'f34': 0.29454026912068965,\n",
       " 'f128': 0.591529846,\n",
       " 'f632': 0.5913791030718749,\n",
       " 'f572': 0.239896293925,\n",
       " 'f114': 0.2633043646,\n",
       " 'f63': 1.00106049,\n",
       " 'f608': 0.508122133325,\n",
       " 'f633': 0.29146133135652186,\n",
       " 'f722': 0.2714358086038462,\n",
       " 'f52': 0.37858963,\n",
       " 'f597': 0.6353617618571429,\n",
       " 'f155': 0.5389254778428572,\n",
       " 'f644': 1.542735497,\n",
       " 'f619': 0.734093483090909,\n",
       " 'f646': 0.22752326716666663,\n",
       " 'f96': 0.2882663098277778,\n",
       " 'f607': 0.29925542737777777,\n",
       " 'f628': 0.4463159180066666,\n",
       " 'f49': 0.8047151415,\n",
       " 'f251': 0.34853560210000006,\n",
       " 'f430': 0.14210136974999998,\n",
       " 'f131': 0.5820275557500001,\n",
       " 'f130': 0.8782157895,\n",
       " 'f615': 0.5347907881428572,\n",
       " 'f70': 0.9728048552428571,\n",
       " 'f400': 0.3188972811666666,\n",
       " 'f50': 0.16110706344999998,\n",
       " 'f492': 0.49620304099999996,\n",
       " 'f20': 0.4259228705,\n",
       " 'f107': 1.18634796,\n",
       " 'f466': 0.20317222353999997,\n",
       " 'f348': 0.48711520399999997,\n",
       " 'f174': 0.202221394,\n",
       " 'f516': 0.318302155,\n",
       " 'f726': 0.30144437166666666,\n",
       " 'f78': 0.45188083572500004,\n",
       " 'f28': 0.289535685347619,\n",
       " 'f513': 0.45205116259999994,\n",
       " 'f248': 0.211374283,\n",
       " 'f164': 0.0455780029,\n",
       " 'f87': 0.1188519091,\n",
       " 'f715': 0.38417995,\n",
       " 'f621': 0.488493919,\n",
       " 'f630': 0.4198728401666667,\n",
       " 'f402': 0.18048600467499998,\n",
       " 'f677': 0.30308227068750004,\n",
       " 'f148': 0.154542923,\n",
       " 'f177': 0.0910744667,\n",
       " 'f408': 0.23073312818333336,\n",
       " 'f109': 0.37923121449999997,\n",
       " 'f123': 0.639780045,\n",
       " 'f640': 0.3043949899333333,\n",
       " 'f617': 0.259383202,\n",
       " 'f366': 0.206139803,\n",
       " 'f272': 0.198157072,\n",
       " 'f709': 0.108273625,\n",
       " 'f680': 0.219274759,\n",
       " 'f489': 0.121016264,\n",
       " 'f479': 0.1019216923,\n",
       " 'f485': 0.0770262666,\n",
       " 'f707': 0.0577668361,\n",
       " 'f668': 0.08287926,\n",
       " 'f711': 0.0961390138,\n",
       " 'f386': 0.0646047071,\n",
       " 'f596': 0.089847751,\n",
       " 'f669': 0.060616236149999995,\n",
       " 'f370': 0.04470064305}"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# q_1\n",
    "importance_dict"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [],
   "source": [
    "ans = q1_model.predict(q2_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([7.803879 , 7.166587 , 7.6466045, 7.518979 , 7.6887503, 7.3576345,\n",
       "       7.4997687, 7.452213 , 7.2296805, 7.748805 , 7.8645363, 7.68379  ,\n",
       "       7.646666 , 7.495641 , 7.2126307, 7.2435436, 7.4607754, 6.7423186,\n",
       "       7.0891495, 9.388802 , 6.8638515, 7.123243 , 6.73722  , 6.921972 ,\n",
       "       6.3099813, 6.4994707, 7.570516 , 6.6353803, 6.407162 , 5.946749 ,\n",
       "       5.363396 , 5.2850304, 5.1170607, 5.563687 , 5.130825 , 6.464286 ,\n",
       "       6.4771204, 6.264259 , 5.867481 , 5.6167564, 5.600303 , 5.600303 ,\n",
       "       5.6325207, 5.8902383, 5.600303 , 6.593472 , 6.669705 , 6.648333 ,\n",
       "       6.851472 , 8.171683 ], dtype=float32)"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# q_2\n",
    "ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
